//////////////////////////////////////////////////
// glCamera.h
//
// Author: Tarik Belabbas et Adrien Hoffer
//////////////////////////////////////////////////

#ifndef GLCAMERA_H_
#define GLCAMERA_H_

#include <GL/gl.h>
#include <glm/glm.hpp>
#include <glm/gtc/quaternion.hpp>

#include "../common/Common.h"

/*#define VIEWPORT_ZOOM_MIN	0.5F	// When zooming in
#define VIEWPORT_ZOOM_MAX	2.75F	// When zooming out
#define VIEWPORT_ZOOM_STEP	0.1F*/
#define	CAM_MOVE_STEP			0.1F

#define CAM_FOV				60.0F
#define CAM_ZNEAR			0.1F
#define CAM_ZFAR			100000.0F

//------------------------------------------------------------------------------
enum glECameraMovementFlag
{
	glECameraMovementFlag_NONE		= 0,			// 0

	glECameraMovementFlag_FORWARD	= ( 1 << 0 ),	// 1
	glECameraMovementFlag_BACKWARD	= ( 1 << 1 ),	// 2
	glECameraMovementFlag_LEFT		= ( 1 << 2 ),	// 4
	glECameraMovementFlag_RIGHT		= ( 1 << 3 ),	// 8

	glECameraMovementFlag_SPEEDX10	= ( 1 << 5 ),	// 32
	glECameraMovementFlag_SPEEDX100	= ( 1 << 6 )	// 64
};

//------------------------------------------------------------------------------
class glCamera
{
public:
	glCamera	();
	~glCamera	();

	void	update		();
	//void	changeZoom		( GLint _delta, GLfloat _viewportRatio );
	void	resizeViewport	( GLfloat _viewportRatio );
	void	updateMove		();

	void	rotateX			( float _angleX );
	void	rotateY			( float _angleY );

	void	enableCamFlag	( glECameraMovementFlag _flag )	{ m_camFlags |= _flag; }
	void	disableCamFlag	( glECameraMovementFlag _flag )	{ m_camFlags &= ~_flag; }

	void	moveCameraTo	( float _posX, float _posY, float _posZ );

	glm::mat4	getModelViewMatrix()	const;

private:
	//void	rotateCamera	( float _angle, const glm::vec3& _axis );
	//void	normalizeAngle	( float& _angle );
	void	setPerspective	( float _yFieldOfView, double _aspect,
								double _zNear, double _zFar );

	// Members
	glm::vec3	m_camPosition;
	glm::vec3	m_camLookPoint;
	glm::vec3	m_camUpVector;

	glm::quat	m_camOrientation;

	int			m_camFlags;
};

#endif /* GLCAMERA_H_ */
